//
//  HNSH_RuleExplainViewController.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/3/10.
//

#import "HNSH_RuleExplainViewController.h"

@interface HNSH_RuleExplainViewController ()

@end

@implementation HNSH_RuleExplainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.view.backgroundColor = [UIColor colorWithHexString:@"#F4F4F4"];
    if (self.type == 1) {
        [self loadConfigRuleInfoWithKey:@"integral_balance"];
    } else if (self.type == 2) {
        [self loadConfigRuleInfoWithKey:@"huibao_dsz"];
    } else if (self.type == 3) {
        [self loadConfigRuleInfoWithKey:@"huibao_pledge_agreement"];
    }
}

- (void)addAllViewsWithDes:(NSString *)des {
    UILabel *label = [[UILabel alloc]init];
    
    label.textColor = [UIColor appBlack333LabelColor];
    label.font = [UIFont systemFontOfSize:14];
    label.numberOfLines = 0;
    [self.view addSubview:label];
    label.text = des;
    
    [label setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(16+kNavBarAndStatusBarHeight);
        make.right.mas_equalTo(-16);
    }];
}

- (void)loadConfigRuleInfoWithKey:(NSString *)key {
    [HNSH_UserNetServer requestConfigRuleInfoWithKey:key success:^(ST_BaseNetModel * _Nullable responseObject) {
        if (responseObject.code == 0) {
            NSString *desString = [NSString stringWithFormat:@"%@",responseObject.resultset[@"content"]];
            if (![desString isNotBlank]) {
                return;
            }
            [self showNavTitle:[NSString stringWithFormat:@"%@",responseObject.resultset[@"title"]] showLeftItem:YES];
            [self addAllViewsWithDes:desString];
        }
    } Failure:^(NSError * _Nullable error) {
        
    }];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
